﻿<MudText>SelectedItems { @string.Join(", ", _selectedItems) }</MudText>
<MudTable Items="_items" @bind-SelectedItems="_selectedItems" MultiSelection="true">
    <HeaderContent>
        <MudTh>Nr</MudTh>
        <MudTh></MudTh>
    </HeaderContent>
    <RowTemplate>
        <MudTd>@context</MudTd>
        <MudTd>
            <MudButton OnClick="(() => DeleteItem(context))">Delete</MudButton>
        </MudTd>
    </RowTemplate>
</MudTable>

@code {
    public static string __description__ = "SelectedItems should update when rows are removed and the header should remain checked.";

    private HashSet<int> _selectedItems = [];
    private readonly List<int> _items = [0, 1, 2, 3, 4];

    private void DeleteItem(int i)
    {
        _items.Remove(i);
        StateHasChanged();
    }
}
